Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore disconnected status while changing region #16285

Merged
merged 3 commits into from
Dec 13, 2022

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Dec 8, 2022

fix brave/brave-browser#27267
fix brave/brave-browser#27196

When user changes region while connected, status should be connecting till region change completes.

Also removed network status checking with IsNetworkAvailable().
Instead of using IsNetworkAvailable(), vpn service will get actual state by issuing network request.

Also do load & save prefs twice when creating vpn entry on macOS to fix connect failure when there is no os vpn entry on macOS

Resolves

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@simonhong simonhong self-assigned this Dec 8, 2022
@simonhong simonhong force-pushed the brave_vpn_change_region_status branch 4 times, most recently from 4647ca6 to 0749bf4 Compare December 9, 2022 07:58
@simonhong simonhong marked this pull request as ready for review December 9, 2022 10:23
@simonhong simonhong force-pushed the brave_vpn_change_region_status branch from 0749bf4 to e8330bb Compare December 9, 2022 10:23
When user changes region while connected, status should be connecting
till region change completes.
@github-actions
Copy link
Contributor

⚠️ PR head is an unsigned commit
commit: 75920b0
reason: unsigned
Please follow the handbook to configure commit signing
cc: @simonhong

// noti again. So, ignore second one.
// On exception - we allow from connecting to disconnected in canceling
// scenario.
// Ignore disconnected state while connecting is in-progress.
Copy link
Member

@bsclifton bsclifton Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These updates to comments lose the context for WHEN this can happen- which is when person is changing regions.

Can we add that back in?

// When user connects to different region while connected,
// we disconnect current connection and connect to newly selected
// region.

Copy link
Member

@bsclifton bsclifton Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait- I missed the actual change to the logic 😅 You're correct to delete this, sorry!

@@ -585,14 +585,6 @@ void BraveVpnService::LoadPurchasedState(const std::string& domain) {
return;
}

#if !BUILDFLAG(IS_ANDROID)
if (!IsNetworkAvailable()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think removing this code is great 👍 LoadPurchasedState is called when person is clicking on VPN button... and if they didn't have network connectivity (briefly, for example), this code would be letting the connection go into FAILED (when no connect ever was made by user).

Nice! 😄 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we cache expiration date, browser will enter to purchased state even network is disabled.
Then, user can get connect failure when user try to connect.
Or it's already expired, browser will ask to refresh skus credential and skus service will make use not purchased state.
So we could get proper state w/o this early checking.

Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@simonhong simonhong merged commit 6cd0038 into master Dec 13, 2022
@simonhong simonhong deleted the brave_vpn_change_region_status branch December 13, 2022 12:29
@github-actions github-actions bot added this to the 1.48.x - Nightly milestone Dec 13, 2022
simonhong added a commit that referenced this pull request Dec 13, 2022
Ignore disconnected status while changing region
@stephendonner
Copy link
Contributor

Verified PASSED using

Brave 1.48.57 Chromium: 108.0.5359.128 (Official Build) nightly (64-bit)
Revision 1cd27afdb8e5d057070c0961e04c490d2aca1aa0-refs/branch-heads/5359@{#1185}
OS Windows 10 Version 22H2 (Build 19045.2364)

Steps:

  1. purchased, set up, and connected to BraveVPN via account.bravesoftware.com
  2. confirmed I was connected to the USA (West) server/region, by default
  3. clicked on the VPN button on the browser toolbar
  4. selected Australia and clicked Connect
  5. confirmed no disconnects or other errors (but the DoH warning dialog*, as expected), while changing connections
  6. selected Spain
  7. confirmed no disconnects or other errors, same as above
BraveVPN connected to USA (West) Australia Spain * DoH warning dialog
image image image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants